package com.dks.filter;


import com.dks.result.ResultModel;

/**
 * token异常变量定义
 *
 * @author Ah Nan
 * @time 2017-08-01
 */
public enum ErrorCodeEnum {

    /**
     * 无效Token.
     */
    ILLEGAL_TOKEN("ILLEGAL_TOKEN", "无效Token"),
    /**
     * 登录已过期.
     */
    UNEXIST_TOKEN("UNEXIST_TOKEN", "登录已过期"),

    /**
     * 账号在其他设备登录.
     */
    COVERED_TOKEN("COVERED_TOKEN", "账号在其他设备登录"),

    /**
     * 账号未登录.
     */
    EMPTY_TOKEN("EMPTY_TOKEN", "账号未登录"),

    /**
     * 账号登录异常.
     */
    TOKEN_EXCEPTION("TOKEN_EXCEPTION", "账号登录异常");

    private String errcode;

    private String errmsg;

    ErrorCodeEnum(final String errcodeIn, final String errmsgIn) {
        this.errcode = errcodeIn;
        this.errmsg = errmsgIn;
    }

    public final String getErrcode() {
        return this.errcode;
    }

    public final String getErrmsg() {
        return this.errmsg;
    }




    public ResultModel<String> toResultModel(){
        return new ResultModel(String.valueOf(getErrcode()),getErrmsg(),"");
    }
    @Override
    public String toString() {
        return String.format("{\"code\": \"%s\",\"msg\": \"%s\",\"data\": \"%s\"}", getErrcode(), getErrmsg(),"");
    }
}
